package com.maschinenstuermer.profiler.transform;

import java.util.logging.Logger;

import org.ow2.util.asm.ClassVisitor;
import org.ow2.util.asm.ClassWriter;

import com.maschinenstuermer.profiler.config.ConfigFactory;

public class ProfilingClassTransformer extends ClassTransfomerTemplate {
	private static Logger logger = Logger.getLogger(ProfilingClassAdapter.class.getName());

	public ClassVisitor createClassVisitor(final String className,
			final ClassWriter classWriter) {
		if (ConfigFactory.profileClass(className.replace("/", "."))) {
			logger.info("Tracing:" + className);
			return new ProfilingClassAdapter(classWriter);
		} else {
			logger.info("Skipping:" + className);
			return null;
		}
	}
	
	@Override
	@SuppressWarnings("unchecked")
	public boolean apply(final Class input) {
		return ConfigFactory.profileClass(input.getName());
	}
}
